import os
import json
from conf import settings


# 保存数据
def save(user_dic):
    user_path = f'{settings.DB_PATH}/{user_dic["user"]}.json'

    with open(user_path,'w',encoding='utf-8') as f:
        json.dump(user_dic,f,ensure_ascii=False)
        f.flush()


# 查看用户数据
def select(user):
    user_path = f'{settings.DB_PATH}/{user}.json'

    if os.path.exists(user_path):

        with open(user_path,'r',encoding='utf-8') as f:
            user_dic = json.load(f)
            return user_dic




